<% content_for :title do %>
  <%=h @artist.name %>
<% end %>

<% content_for :edit do %>
  <%= link_to 'Delete Entry?', 
              new_delete_request_path(:editable_id => @artist.id, 
                                      :editable_type => "Artist") %> |

  <% if session[:edit_mode] == false %>
    <%= link_to 'Edit This Page', edit_artist_path %> 
  <% else %>
    <%= link_to 'Finish Editing', artist_path %> 
  <% end %>
<% end %>

<table id="entry-table">

  <tr id="entry-table-row1">

    <td id="entry-top-pane">
      <span class="entry-title">
        <%=h @artist.name %>
      </span>

      <div id="top-tools">
        <% if @favorite.nil? %>
          <% if permitted_to? :create, :favorites %>
            <%= link_to 'Favorite', add_favorite_path(:id => @artist.id,
                                                      :type => 'Artist') %>
          <% end %>
        <% else %>
          <% if permitted_to? :destroy, :favorites %>
            <%= link_to 'Remove From Favorites', remove_favorite_path(:id => @favorite) %>
          <% end %>
        <% end %>
      </div><!-- /top-tools -->

    </td>
  </tr><!-- /entry-table-row1 -->
  
  <tr id="entry-table-row2">

    <td class="entry-left-pane">

      <div id="entry-left-image">
        <%= render :partial => 'images/image_viewer',
                   :locals => {:item => @artist,
                               :gallery_path => artist_images_path(@artist) } %>
      </div><!-- /entry-left-image -->

    </td><!-- /entry-left-pane -->

    <td class="entry-mid-pane">

      <table id="entry-mid-info">

        <% if @artist.is_group == false %>
          <tr>
            <td class="entry-info-label">Birth Name:</td>
            <td><%=h @artist.proper_name %></td>
          </tr>
     
          <tr>
            <td class="entry-info-label">Gender:</td>
            <td><%=h @artist.gender %></td>
          </tr>
        <% end %>

        <tr>
          <td class="entry-info-label">Aliases:</td>
          <td>
            <%- @artist.name_aliases.each do |name| -%>
              <%=h name.name %><%= (name == @artist.name_aliases.last) ? "" : "," %>
            <%- end -%>
          </td>
        </tr>

		<% @artist.ordered_dates.each do |d| %>
		  <tr>
		    <td class="entry-info-label">
			  <%=h d.event %>:
			</td>
			<td>
			  <%=h d.date_string_with_month %>
			</td>
		  </tr>
		<% end %>

		<% if @artist.location %>
        <tr>
          <td class="entry-info-label">Hometown:</td>
          <td><%=h @artist.location.city %><%=h (@artist.location.state.nil?)? "" : ", " + @artist.location.state %></td>
        </tr>

        <tr>
          <td class="entry-info-label">Country:</td>
          <td><%=h @artist.location.country %></td>
        </tr>
		<% end %>

        <tr>
          <td class="entry-info-label">Genre:</td>
          <td>
            <% @artist.genres.each do |genre| %>
              <strong><%= link_to genre.name, genre %></strong>
            <% end %>
          </td>
        </tr>

      </table><!-- /entry-mid-info -->
    </tr><!-- /entry-table-row2 -->

    <tr id="entry-table-row3">

      <td class="entry-left-pane">
        <div id="entry-left-menu">
          <ul class="tabnav">
            <%= artist_tab('Bio', 'bio-pane', 'active') %>
            <%= artist_tab('Releases', 'discog-pane', 'inactive') %>
            <%= artist_tab('Songs', 'song-pane', 'inactive') %>
            <%= artist_tab('Discuss', 'forum-pane', 'inactive') %>
            <% if @artist.is_group == true %>
              <%= artist_tab('Members', 'bands-members-pane', 'inactive') %>
            <% else %>
              <%= artist_tab('Bands', 'bands-members-pane', 'inactive') %>
            <% end %>
            <%= artist_tab('Reviews', 'review-pane', 'inactive') %>
          </ul>
        </div><!-- /entry-left-menu -->
      </td>

     <td class="entry-mid-pane">
      <div id="entry-mid-content">

        <div id="bio-pane">
          <h2>Biography</h2>
          <%= simple_format(@artist.bio) %>
          <br />
        </div><!-- /bio-pane -->

        <div id="discog-pane" style="display: none">

          <h2>Releases</h2>

          <div id="discog-nav">
            Sort By: 
            <% @artist.release_types.each do |type| %>
              <%= link_to_remote type.to_s, :url => release_set_artist_path(@artist, :type => type.to_s),
											:method => :get,
                                            :update => 'discog-results',
                                            :loading => "Element.hide('releases'), Element.show('progress_indicator')",
                                            :loaded => "Element.show('releases')" %>
              
              <%= (type != @artist.release_types.last)? ' | ' : ' ' %>
              
            <% end %>

          </div><!-- /discog-nav -->

          <div id="discog-results">
            <%= render :partial => 'release', :locals => { :category => "All", :releases => @artist.releases } %>
          </div><!-- /discog-results -->

        </div><!-- /discog-pane -->

        <div id="song-pane" style="display: none">
          <h2>Songs</h2>
          <% if @artist.songs.empty? %>
            There are no songs for this artist.
          <% else %>

            <%= render :partial => 'songs/list_songs',
                       :locals => { :songs => @artist.songs } %>
          <% end %>
        </div><!-- /song-pane -->

        <div id="forum-pane" style ="display: none">
          <h2><%=h @artist.forum.title %></h2>
          <%= render :partial => "forums/forum", :locals => {:forum => @artist.forum } %>
        </div><!-- /forum-pane -->

        <div id="bands-members-pane" style="display: none">
          <%- if @artist.is_group == true -%>
            <h2>Members</h2>
            <%= render :partial => "members", :locals => {:artist => @artist} %>
          <%- else -%>
            <h2>Bands</h2>
            <%= render :partial => "bands", :locals => {:artist => @artist} %>
          <%- end -%>
        </div><!-- /bands-members-pane -->

        <div id="review-pane" style="display: none">
          <h2>Reviews</h2>
          <%= render :partial => 'reviews/review', :locals => {:item => @artist} %>
        </div><!-- /review-pane -->

      </div><!-- /entry-mid-content -->
    </td>
  </tr>
</table>
